package com.liushuai.eas.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.liushuai.eas.mapper.ClassesMapper;
import com.liushuai.eas.mapper.DepartmentMapper;
import com.liushuai.eas.mapper.MajorMapper;
import com.liushuai.eas.pojo.Classes;
import com.liushuai.eas.pojo.Major;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Service
public class ClassesImp implements ClassesMapper {

    @Resource
    private ClassesMapper classMapper;

    @Resource
    private MajorMapper majorMapper;

    @Resource
    private DepartmentMapper departmentMapper;

    @Override
    public int insert(Classes entity) {
        return classMapper.insert(entity);
    }

    @Override
    public int deleteById(Serializable id) {
        return classMapper.deleteById(id);
    }

    @Override
    public int deleteById(Classes entity) {
        return classMapper.deleteById(entity);
    }

    @Override
    public int deleteByMap(Map<String, Object> columnMap) {
        return 0;
    }

    @Override
    public int delete(Wrapper<Classes> queryWrapper) {
        return 0;
    }

    @Override
    public int deleteBatchIds(Collection<?> idList) {
        return 0;
    }

    @Override
    public int updateById(Classes entity) {
        return classMapper.updateById(entity);
    }

    @Override
    public int update(Classes entity, Wrapper<Classes> updateWrapper) {
        return 0;
    }

    @Override
    public Classes selectById(Serializable id) {
        return classMapper.selectById(id);
    }

    @Override
    public List<Classes> selectBatchIds(Collection<? extends Serializable> idList) {
        return null;
    }

    @Override
    public List<Classes> selectByMap(Map<String, Object> columnMap) {
        return null;
    }

    @Override
    public Classes selectOne(Wrapper<Classes> queryWrapper) {
        return classMapper.selectOne(queryWrapper);
    }

    @Override
    public Long selectCount(Wrapper<Classes> queryWrapper) {
        return null;
    }

    @Override
    public List<Classes> selectList(Wrapper<Classes> queryWrapper) {
        return classMapper.selectList(queryWrapper);
    }

    @Override
    public List<Map<String, Object>> selectMaps(Wrapper<Classes> queryWrapper) {
        return null;
    }

    @Override
    public List<Object> selectObjs(Wrapper<Classes> queryWrapper) {
        return null;
    }

    @Override
    public <P extends IPage<Classes>> P selectPage(P page, Wrapper<Classes> queryWrapper) {
        return classMapper.selectPage(page, queryWrapper);
    }

    @Override
    public <P extends IPage<Map<String, Object>>> P selectMapsPage(P page, Wrapper<Classes> queryWrapper) {
        return null;
    }

    @Override
    public List<Classes> queryClassesList(int pageBegin, int pageEnd) {
        return classMapper.queryClassesList(pageBegin,pageEnd);
    }

    @Override
    public List<Classes> queryClassesListBySearch(int pageBegin, int pageEnd, String search) {
        return classMapper.queryClassesListBySearch(pageBegin,pageEnd,search);
    }

    @Override
    public int queryTotal() {
        return classMapper.queryTotal();
    }

    @Override
    public int queryTotalBySearch(String search) {
        return classMapper.queryTotalBySearch(search);
    }

    @Override
    public Classes selectOne(Integer id) {
        Classes classes = classMapper.selectOne(id);
        Major major = majorMapper.selectOne(classes.getMajorId());
        major.setDepartment(departmentMapper.selectOne(major.getDepartmentId()));
        classes.setMajor(major);
        return classes;
    }

    @Override
    public Classes queryClassesByName(String name) {
        return classMapper.queryClassesByName(name);
    }
}
